<template>
	<div class="hd">
		<!-- <img src="../../../assets/mobile/img/zt666.jpg" /> -->
		<router-link to="/home" style="padding-left: 13%;">首页</router-link>
		<el-button style="padding-left: 35%; border: none;background-color: transparent;" v-show="!judge"
			@click="gologin()">登录</el-button>
		<router-link to="/updateAdmin" style="padding-left: 35%;" v-show="judge">{{user.name}}</router-link>
		<el-button class="addadmin" @click="goadd()">注册账号</el-button>
		<el-button class="exit" @click="exits()">退出</el-button>
		<router-link to="/mobile/home">前往App</router-link>
	</div>
</template>

<script>
	import {
		mapActions,
		mapState
	} from 'vuex'
	export default {
		name: 'Head',
		data() {
			return {
				judge: false,
				adminname: ''
			}
		},
		methods: {
			gologin() {
				this.$router.push('/login');
			},
			exits() {
				window.localStorage.clear();
				this.judge = false;
			},
			goadd() {
				this.$router.push('/addAdmin');
			}
		},
		mounted() {
			console.log("3" + this.judge);
			this.judge = this.$route.query.jd;
			this.adminname = this.$route.query.admin;
		},
		computed: {
			...mapState('search', ['user']),

		},

	}
</script>

<style scoped>
	.hd {
		width: 100%;
		height: 30px;
		background-color: #f0eff2;
		margin: 0 auto;
	}

	.hd button.addadmin {
		border: none;
		background-color: transparent;
	}

	.hd button.exit {
		padding-left: 23%;
		text-align: right;
		border: none;
		background-color: transparent;
	}
</style>